package cn.tedu.spring.life;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;

/**
 * javaBean对象的生命周期演示
 */
@Component
public class Life {
    private String mean;

    public Life() {
        System.out.println("第一步！通过无参构造方法实例化");

    }
    @Value("生命的意义在于享受世界！")
    public void setMean(String mean) {
        this.mean = mean;
        System.out.println("第二步！通过set方法进行属性赋值");
    }

    @PostConstruct
    public void init(){
        System.out.println("第三步！通过PostConstruct注解生命周期初始化");
    }

    @PreDestroy
    public  void destory(){
        System.out.println("第五步！通过PreDestory注解来销毁JavaBean对象");
    }


}
